
import { Injectable } from '@angular/core';
import { HttpHeaders, HttpClient, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';

import { environment } from '../environments/environment';
import { Deliver } from '../models/Deliver';

@Injectable()
export class DeliverService {

  private baseUrl = environment.apiUrl + 'api/assetdeliver';

  constructor(
    private http: HttpClient
  ) {}
  getList(assetId: string): Observable<{res: Deliver[], success: boolean, total: number}> {
    let params: HttpParams = new HttpParams();
    // params = params.append('page', String(current + 1));
    // params = params.append('pageSize', String(pageSize));
    params = params.append('assetId', assetId);
    return this.http.get<{res: Deliver[], success: boolean, total: number}>(`${this.baseUrl}/getlist`, { params: params });
  }
  create(deliver: Deliver): Observable<{success: boolean, res: Deliver}> {
    return this.http
      .post<{success: boolean, res: Deliver}>(`${this.baseUrl}/insert`, deliver);
  }
}
